<?php
Box::$description["Image"] = "An image";
/**
*Manage an imaged. The image is embedded into the atom itself.
*@author Willy Gardiol <willy@gardiol.org>
*@version 1.0
*@package Boxes
*@subpackage Image
*/
class Box_Image extends Box
{
	private $picture = false;
	public function __construct( $title )
	{
		parent::__construct($title,"popup",'box:Image/BoxImage');
		$this->picture = new Box_Image_Picture("picture");
	}
	protected function PostInitialize()
	{
		$this->SetStorage( array("url" => "") );
		$this->AddEditTab( "box:Image/BoxImageEdit",
							I18N("Modify/Upload image..."),
							I18N("Upload & Save..."),
							"SaveImage" );

	}
	protected function SaveImage( $request )
	{
		$this->picture->Save() && $request->SetReload(true);

		$url = Core::POSTVar("picture_url", false, "string");
		if ( $url === "" )
			$url = false;
		$this->Set("url", $url) && $request->SetReload(true);

		echo I18N("Picture saved ($url)!");
	}

	protected function ProcessData( $data )
	{
		return $this->picture->ProcessData( $data );
	}
}
?>